package done.easy_401_500;

import lombok.extern.slf4j.Slf4j;
import org.junit.Test;

import java.util.*;

/**
 * 500. Keyboard Row  键盘行
 * <p>
 * 给定一个单词列表，只返回可以使用在键盘同一行的字母打印出来的单词。键盘如下图所示。
 * 示例：
 * 输入: ["Hello", "Alaska", "Dad", "Peace"]
 * 输出: ["Alaska", "Dad"]
 * <p>
 * String s1 = "qwertyuiop";
 * String s2 = "asdfghkjl";
 * String s3 = "zxcvbnm";
 *
 * @author 大硕
 * 2019-03-29 10:39 PM
 **/
@Slf4j
public class KeyboardRow {

    @SuppressWarnings("all")
    public String[] findWords(String[] words) {
        // 190409 first
        return null;
    }

    @Test
    @SuppressWarnings("all")
    public void test() {
        String[] words = new String[]{"Hello", "Alaska", "Dad", "Peace"};
        String[] s = findWords(words);
        log.info("result:{}", Arrays.asList(s));
    }
}






























/*
public String[] findWords(String[] words) {
    Map<Character,Integer> map = new HashMap<>();
    String line1 = "qwertyuiop";
    String line2 = "asdfghkjl";
    String line3 = "zxcvbnm";
    List<String> list = new ArrayList<>();

    for (char c : line1.toCharArray()) {
        map.put(c, 1);
    }

    for (char c : line2.toCharArray()) {
        map.put(c, 2);
    }

    for (char c : line3.toCharArray()) {
        map.put(c, 3);
    }

    for (String word : words) {
        int num = map.get(word.toLowerCase().charAt(0));

        for (int i=0; i<word.length(); i++) {
            if (num!=map.get(word.toLowerCase().charAt(i))) {
                break;
            }

            // 如果运行到了最后 就代表里面全都是同一行字母
            if (i==(word.length()-1)) {
                list.add(word);
            }
        }
    }
    return list.toArray(new String[0]);
}
*/
